import { request } from '@umijs/max';

export async function getFileList(options?: { [key: string]: any }) {
  return request<{
    data: API.DownloadFile[];
  }>('/api/file/download/list', {
    method: 'GET',
    ...(options || {}),
  });
}


export async function directUploadFile(body: FormData, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/file/direct-upload', {
    method: 'POST',
    data: body,
    ...(options || {}),
  });
}



export async function fragmentUploadPrepare(body: API.FileMeta, options?: { [key: string]: any }) {
  return request<{
    data: Array<number>;
  }>('/api/file/prepare-upload', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}


export async function fragmentUploadSlice(body: FormData, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/file/upload-slice', {
    method: 'POST',
    data: body,
    ...(options || {}),
  });
}


export async function fragmentUploadFinished( body: API.FileMeta, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/file/finish-upload', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

